<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Sistema de Administraci&oacute;n de Condominios - Mantenimiento de Residentes</title>
<%@include file="include/header.jsp" %>
</head>
<body>
<%@include file="include/menu.jsp" %>

    		 <%
		
		Persona vo = (Persona)session.getAttribute("user");
		
		if (vo== null){
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
			return;
		}
	  %>
<div class="container">
	<div class="hero-unit" align="center">
	    	<h2><strong>Busqueda de Residentes</strong></h2><br>
	 </div>
		  
<%@page import="java.util.ArrayList,condominios.modelo.Persona"%>
<form id = "formaPaginar" method="post" action="ResidenteUpdateServlet">
	<div class="row">
		<div class="col-md-12">
		<%	
				
			ArrayList<Persona> personasFull = (ArrayList<Persona>) request.getAttribute("RESIDENTES");
			if (personasFull != null) {%>
		<div class="table-responsive">
			<table id="tablaBuscar" class="table table-striped table-bordered table-condensed">
  				<tr id = "fila1">
  					<th id= "celda1">Id Persona</th>
  					<th>DNI</th>
  					<th>Nombres</th>
  					<th>Apellido Paterno</th>
  					<th>Apellido Materno</th>
  					<th>Email</th>
  					<th>Perfil</th>
  					<th></th>
  				</tr>
  				<% 
  				int minFila = (int) request.getAttribute("MINROW");
  				int maxFila = (int) request.getAttribute("MAXROW");
  			
  				for (int i=0; i<=maxFila; i++) {
  				%>
  				<tr>
  					<td><%=personasFull.get(i).getIdPersona()%></td>
  					<td><%=personasFull.get(i).getDni()%></td>
  					<td><%=personasFull.get(i).getNombres()%></td>
  					<td><%=personasFull.get(i).getApellidoPaterno()%></td>
  					<td><%=personasFull.get(i).getApellidoMaterno()%></td>
  					<td><%=personasFull.get(i).getEmail()%></td>
  					<td><%=personasFull.get(i).obtenerCadenaPerfil(personasFull.get(i).getIdPerfil())%></td>
  					<td>
  						<button type="submit" class="btn btn-default" aria-label="Left Align" name="residente<%=Integer.toString(personasFull.get(i).getIdPersona())%>">
  						<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
						</button>
						<button type="submit" class="btn btn-default" aria-label="Left Align" name="residented<%=Integer.toString(personasFull.get(i).getIdPersona())%>">
  						<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
						</button>
  					
  					</td>
  					
  				</tr>
  				<%
  						}
  				%> 					
			</table>
						
				</div>
			</div>
			
			<div class="row">		
  			<div class="col-md-6" align="left">
  				<nav>
			  	<ul class="pagination">
			    <li>
			      <a href="#" aria-label="Previous">
			        <span aria-hidden="true">&laquo;</span>
			      </a>
			    </li>
			    <li><a href="#">1</a></li>
			    <li><a href="#">2</a></li>
			    <li><a href="#">3</a></li>
			    <li><a href="#">4</a></li>
			    <li><a href="#">5</a></li>
			    <li>
			      <a href="#" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
			  </ul>
			</nav>
  			</div>
  			<div class="col-md-6" align="right">
  				Items por pagina: <select id= "selCanId" onchange="irServletBuscar()">
					<option value="5">5</option>
					<option value="10">10</option>
					<option value="20">20</option>					
				</select>
				<p id="demo">Esta es una prueba</p>
				<script>
				function irServletBuscar() {
					
				    var x = document.getElementById("selCanId").value;
				    document.getElementById("demo").innerHTML = "You selected: " + x;				  			
				   	document.getElementById("celda1").innerHTML = "Anterior";
				   	
				   	var z = document.createElement("TR");
				    z.setAttribute("id", "myTr");
				    document.getElementById("tablaBuscar").appendChild(z);

				    var y = document.createElement("TD");
				    var t = document.createTextNode("Tulipan");
				    y.appendChild(t);
				    document.getElementById("myTr").appendChild(y);
				    
				    document.getElementById("formaPaginar").submit();
				    				    
				}
				</script> 		 
  				</div>
			</div>		
		</div>	
		
			<%
  				}
  				%>  								
</form>		
</div>
	
</body>
	 <footer>
	 <div class="container">
		 <div class="row">		
	  		<div class="col-md-12" align="center">		 	
	        		<p>&copy; Java Tigers 2015</p>			
			</div>				
		</div>		
	</div>
	 </footer>
</html>